﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Linq.Expressions;
using ApiCoreProject.Model.Entities;
using ApiCoreProject.Bll.Interface;
using ApiCoreProject.Dal;
using System.Dynamic;


namespace ApiCoreProject.Bll.Implement
{
    class OrganizationServe : BaseBll<Department>, IOrganizationServe
    {
        public OrganizationServe(IBaseDal<Department> dal) : base(dal)
        {
        }

        public dynamic GetOrganizationAll()
        {
            var depts = dal.GetModels(d => true);

            dynamic d = new ExpandoObject();
            var o = (from dept in depts
                    select new
                    {
                        dept.DeptId,
                        dept.DeptName,
                        dept.Type,
                        dept.Remark,
                        dept.LastTime,
                        dept.Roles
                    }).ToList();

            d.code = o == null ? 0 : 1;
            d.msg = o == null ? "没有查询到数据！" : "查询完成";
            d.data = o;

            return d;
        }
    }
}
